package com.cta.view.model.report;

import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.cta.constant.ReportTypeConst;
import com.cta.utils.CDRStringUtils;

public class ReportParams {

	private String type;
	private String entity;
	private String period;

	public ReportParams(String type, String entity, String period) {
		this.type = type;
		this.entity = entity;
		this.period = period;
	}

	public ReportTypeConst getType() {
		if (type != null) {
			return ReportTypeConst.lookup(type);
		}
		return null;
	}

	public void setType(String type) {
		this.type = type;
	}

	public EntityParams getEntity() {
		if (StringUtils.isNotEmpty(entity)) {
			Map entityMap = CDRStringUtils.parseJsonType(entity, Map.class);
			return new EntityParams(entityMap);
		}
		return null;
	}

	public void setEntity(String entity) {
		this.entity = entity;
	}

	public PeriodParams getPeriod() {
		if (StringUtils.isNotEmpty(period)) {
			Map periodMap = CDRStringUtils.parseJsonType(period, Map.class);
			return new PeriodParams(periodMap);
		}
		return null;
	}

	public void setPeriod(String period) {
		this.period = period;
	}

}
